package com.mybatis.controller;

import com.mybatis.entity.TUser;
import org.springframework.web.HttpRequestHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * Created by 85243 on 2017/5/19.
 */
public class UserController2 implements HttpRequestHandler{
    @Override
    public void handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
        List<TUser> userList = new ArrayList<>();

        TUser user1= new TUser();
        user1.setName("傻狗");
        user1.setId(1);
        userList.add(user1);
        TUser user2= new TUser();
        user2.setName("猪脑子");
        user2.setId(2);
        userList.add(user2);
        httpServletRequest.setAttribute("userList",userList);
        httpServletRequest.getRequestDispatcher("/jsp/user/userList.jsp").forward(httpServletRequest,httpServletResponse);
    }
}
